import { defineStore } from 'pinia'

export const useThemeStore = defineStore('theme', {
    state: () => ({
        currentTheme: localStorage.getItem('theme') || 'blue',
        themes: [
            { name: 'blue', label: '蓝色主题' },
            { name: 'green', label: '绿色主题' },
            { name: 'purple', label: '紫色主题' },
            { name: 'orange', label: '橙色主题' }
        ]
    }),

    actions: {
        setTheme(themeName) {
            this.currentTheme = themeName
            document.documentElement.setAttribute('data-theme', themeName)
            localStorage.setItem('theme', themeName)
        },
        initTheme() {
            document.documentElement.setAttribute('data-theme', this.currentTheme)
        }
    }
})
